package com.zhengsr.wanandroid.activity;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.zhengsr.corelib.bean.CollectBean;
import com.zhengsr.wanandroid.R;
import com.zhengsr.wanandroid.mvp.base.BaseActivity;
import com.zhengsr.wanandroid.mvp.contract.ContractManager;
import com.zhengsr.wanandroid.mvp.present.CollectPresent;
import com.zhengsr.wanandroid.ui.main.adapter.HomeAdapter;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

/**
 * Created by zhengshaorui
 * time: 2018/10/7
 */

public class CollectActivity extends BaseActivity<CollectPresent> implements ContractManager.ICollectView, BaseQuickAdapter.OnItemChildClickListener {




    private CollectPresent mPresent;

    @BindView(R.id.collect_recy)
    RecyclerView mRecyclerView;
    private List<CollectBean> mArticleBeans = new ArrayList<>();
    private HomeAdapter mAdapter;
    @BindView(R.id.common_toolbar)
    Toolbar mToolbar;



    @Override
    public int getLayoutId() {
        return R.layout.fragment_collect;
    }

    @Override
    public CollectPresent getPresent() {
        mPresent = CollectPresent.create(this);
        return mPresent;
    }

    @Override
    public void initView() {
        LinearLayoutManager manager = new LinearLayoutManager(this);
        mRecyclerView.setLayoutManager(manager);
        mAdapter = new HomeAdapter(R.layout.item_article_recy_layout, mArticleBeans);

        mRecyclerView.setAdapter(mAdapter);
        mAdapter.setOnItemChildClickListener(this);
        mAdapter.setCollected(true);
        mPresent.getCollectList();
        mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }



    @Override
    public void getCollectData(List<CollectBean> datas) {
        mArticleBeans.clear();
        mArticleBeans.addAll(datas);
        mAdapter.notifyDataSetChanged();
    }

    @Override
    public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {

    }
}
